from fastapi import APIRouter
from typing import List, Dict
from ...service.backtest_runner import BacktestRunner

router = APIRouter()

@router.get("/backtests", response_model=List[Dict])
async def get_backtests():
    """获取所有回测记录"""
    return await BacktestRunner.get_history()

@router.get("/backtests/{backtest_id}", response_model=Dict)
async def get_backtest_detail(backtest_id: str):
    """获取回测详细信息"""
    return await BacktestRunner.get_details(backtest_id)

@router.post("/backtests/run")
async def run_backtest(params: Dict):
    """执行新的回测"""
    return await BacktestRunner().execute(params)